import Vue from "vue";

import confirmBox from "@/components/confirm/ConfirmBox.vue";
let ConfirmConstructor = Vue.extend(confirmBox);

let theConfirm = function (text) {

    return new Promise((res, rej) => {
        let confirmDom = new ConfirmConstructor({
            el: document.createElement("div")
        })
        document.body.appendChild(confirmDom.$el);
        confirmDom.text = Object.assign({}, confirmDom.text, text);
        confirmDom.confirm = function () {
            confirmDom.isShow = false;
            res();
        }
        confirmDom.cancel = function () {
            confirmDom.isShow = false;
            rej();
        }
    })
}

export default theConfirm;
